<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div>
    <p>hello world</p>
    <div id="shadow"></div>
  </div>

  <script>
    // DOM API
    let shadowDOM = document.getElementById('shadow').attachShadow({ mode: 'closed' }) // 外界无法访问 shadow dom
    let pElm = document.createElement('p')
    pElm.innerHTML = 'hello zhj'
    let styleElm = document.createElement('style')
    styleElm.textContent = `
      p{ color: red }
    `
    shadowDOM.appendChild(styleElm)
    // shadowDOM.appendChild(pElm)

    // 失效
    // document.body.appendChild(pElm) 
    // react 项目 弹框
  </script>
</body>
</html>